package kr.hkit.powerjava.chapter22.mywork;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentManage implements DaoInterface<Student> {

	private ArrayList<Student> arList;
	
	
	public StudentManage() {
	}

	public StudentManage(ArrayList<Student> arList) {
		this.arList = arList;
	}

	public void addItem(Student std){
		arList.add(std);
	}
	
	public void delItem(Student std){
		if(arList.contains(std)){
			arList.remove(arList.indexOf(std));
		}else{
			System.out.println("해당 학생 정보 없음");
		}
	}
	
	public void prnList(){
		System.out.println("------------------------------------------------------");
		prnHeader();
		for(Student std: arList){
			System.out.println(std);
		}
	}
	
	public void prnHeader() {
		String header = String
		.format("%3s\t%5s\t%3s\t%3s\t%3s\t%4s\t%5s",
				"학번", "성명", "국어", "영어", "수학", "총점", "평균");
		System.out.println(header);
	}
	
	public Student searchItem(Student std){
		if(arList.contains(std)){
			return arList.get(arList.indexOf(std));
		}else{
			return null;
		}
	}
	
	public void updateItem(Student item){
		arList.set(arList.indexOf(item), item);
//		if(searchItem(std) != null){
//			Scanner input = new Scanner(System.in);
//			System.out.print("국어 영어 수학 순으로");
//			std.setKorScore(input.nextInt());
//			std.setEngScore(input.nextInt());
//			std.setMathScore(input.nextInt());
//			arList.set(arList.indexOf(std), std);
//			return std;
//		}
//		return null;
	}
}
